package com.yang.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RefreshScope
@RestController
public class ConsumerController {

    @Value("${server.port}")
    private String ip;

    @Value("${qq.username}")
    private String username;

    @Value("${qq.pwd}")
    private String pwd;

    @GetMapping("/hi")
    public String hi() {
        return "hi " + ip;
    }

    @GetMapping("/consumer")
    public String consumer(HttpServletRequest request) {
        String token = request.getHeader("Authorization");
        System.out.println();
        if (token == null) {
            return "ip: " + ip + " not login";
        }
        System.out.println("接收到的请求头: " + token);
        return "consumer " + username + "---" + pwd + "---port: " + ip;
    }
}
